package com.seaboxdata.utils;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.HashMap;
import java.util.Map;

/**
 * @author
 * @create 2021-04-27 17:19
 **/
public class TestHttp {
    public static void main(String[] args) {

        JSONObject jsonParam = new JSONObject();
        jsonParam.put("accessKey", "QJ_DPXQZJJ");
        jsonParam.put("secretKey", "72440cf6275296e49222cf45a1ac34f74a0340fa8838ee52");

        Map<String, String> headerMap = new HashMap<>();
        headerMap.put("content-type", "application/json");
        try {
            HttpUtils.Response response = HttpUtils.doPost("http://139.9.1.59:8080/szsti-jf/user/token", jsonParam.toJSONString(), "utf-8", headerMap);
            if(response.getStatusCode() == 200){
                Gson gson = new Gson();
                Map<String, Object> map = gson.fromJson(response.getResponseData(), new TypeToken<Map<String, Object>>() {
                }.getType());
               //return (String) ((Map) map.get("data")).get("token");

                System.out.println(map);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
